﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace A.HTMlServer
{
    public class MThread
    {
        public MThread()
        {
 
        }

        public void start()
        {
            Thread Th = new Thread(Main);
            Th.Start();
        }

        private void Main()
        {
            HListModel model=null;
            ArticleModel Amodel = null;
            do{
                lock(Control.objState)
                {
                    if (Control.HList.Count > 0)
                    {
                        model =Control.HList[0];
                        Control.HList.RemoveAt(0);
                        Amodel = new CrawlArticle().ToPage(model);
                        if (Amodel != null)
                        {
                            Control.List.Add(Amodel);
                            //下载一条保存一条
                            A.HTMlServer.ArticleData.DatatoSqlArticle(Amodel);
                        }
                    }
                    else
                    {
                        Control.ActiveState = false;
                    }
                }
                Thread.Sleep(500);
            }while(Control.ActiveState);
        }
    }
}
